package castledefense.logic.missile;

import castledefense.logic.Targetable;

public final class Missile {
	final Targetable target;
	public double x;
	public double y;

	final double damage;
	final int type;
	final int level;
	private final static double speed = 0.0125;

	Missile(Targetable target2, double startX, double startY, double damage, int type,
			int level) {
		this.target = target2;
		this.x = startX;
		this.y = startY;
		this.damage = damage;
		this.type = type;
		this.level = level;
	}

	final boolean update(int delta) {

		double dx = target.getCenterX() - x;
		double dy = target.getCenterY() - y;
		final double value = delta * speed;
		final double len = Math.sqrt((dx * dx + dy * dy));
		dx /= len;
		dy /= len;
		x += dx * value;
		y += dy * value;

		if (target.contains(x, y)) {
			return true;
		}
		return false;
	}

	// final void render() {

	// }
}
